]> git.r.bdr.sh - rbdr/super-polarity/blame - Super Polarity/SuperPolarity.cs
I have the worst commits ever.
[rbdr/super-polarity] / Super Polarity / SuperPolarity.cs
CommitLineData
63a61ee2
BB
1#region Using Statements
2using System;
3using System.Collections.Generic;
4using Microsoft.Xna.Framework;
5using Microsoft.Xna.Framework.Content;
6using Microsoft.Xna.Framework.Graphics;
7using Microsoft.Xna.Framework.Input;
8using Microsoft.Xna.Framework.Storage;
9using Microsoft.Xna.Framework.GamerServices;
10using SuperPolarity;
11#endregion
12
13namespace SuperPolarity
14{
15 /// <summary>
16 /// This is the main type for your game
17 /// </summary>
18 public class SuperPolarity : Game
19 {
74c15570 20 public GraphicsDeviceManager graphics;
63a61ee2
BB
21 SpriteBatch spriteBatch;
22
38c7d3f9
BB
23 public static int OutlierBounds;
24
74c15570
BB
25 public Player Player;
26
27 Screen EntryScreen;
28
29 SpriteFont DebugFont;
30
63a61ee2
BB
31 public SuperPolarity()
32 : base()
33 {
74c15570
BB
34 graphics = new GraphicsDeviceManager(this);
35 graphics.PreferMultiSampling = true;
36 graphics.PreferredBackBufferWidth = 1280;
37 graphics.PreferredBackBufferHeight = 720;
38 graphics.ToggleFullScreen();
39
63a61ee2 40 Content.RootDirectory = "Content";
2af83e98 41 ActorFactory.SetGame(this);
38c7d3f9
BB
42 ParticleEffectFactory.SetGame(this);
43 ActorManager.SetGame(this);
74c15570
BB
44 ScreenManager.SetGame(this);
45
46 EntryScreen = (Screen)new GameScreen(this);
63a61ee2
BB
47 }
48
49 /// <summary>
50 /// Allows the game to perform any initialization it needs to before starting to run.
51 /// This is where it can query for any required services and load any non-graphic
52 /// related content. Calling base.Initialize will enumerate through any components
53 /// and initialize them as well.
54 /// </summary>
55 protected override void Initialize()
56 {
63a61ee2 57 base.Initialize();
2af83e98 58
74c15570
BB
59 InputController.RegisterEventForKey("fullScreenToggle", Keys.F11);
60 InputController.Bind("fullScreenToggle", HandleFullScreenToggle);
38c7d3f9 61
74c15570
BB
62 EntryScreen.Initialize();
63 ScreenManager.Push(EntryScreen);
2af83e98 64
74c15570
BB
65 OutlierBounds = 100;
66 }
67
68 protected void HandleFullScreenToggle(float value)
69 {
70 graphics.ToggleFullScreen();
71 graphics.ApplyChanges();
63a61ee2
BB
72 }
73
74 /// <summary>
75 /// LoadContent will be called once per game and is the place to load
76 /// all of your content.
77 /// </summary>
78 protected override void LoadContent()
79 {
80 // Create a new SpriteBatch, which can be used to draw textures.
81 spriteBatch = new SpriteBatch(GraphicsDevice);
82
74c15570 83 EntryScreen.LoadContent();
63a61ee2 84
74c15570
BB
85 Player = new Player();
86 DebugFont = Content.Load<SpriteFont>("Fonts\\SegoeUIMono14");
63a61ee2
BB
87 }
88
89 /// <summary>
90 /// UnloadContent will be called once per game and is the place to unload
91 /// all content.
92 /// </summary>
93 protected override void UnloadContent()
94 {
95 // TODO: Unload any non ContentManager content here
96 }
97
98 /// <summary>
99 /// Allows the game to run logic such as updating the world,
100 /// checking for collisions, gathering input, and playing audio.
101 /// </summary>
102 /// <param name="gameTime">Provides a snapshot of timing values.</param>
103 protected override void Update(GameTime gameTime)
104 {
105 if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
106 Exit();
107
74c15570 108 ScreenManager.Update(gameTime);
95d7601b 109
63a61ee2
BB
110 base.Update(gameTime);
111 }
112
113 /// <summary>
114 /// This is called when the game should draw itself.
115 /// </summary>
116 /// <param name="gameTime">Provides a snapshot of timing values.</param>
117 protected override void Draw(GameTime gameTime)
118 {
95d7601b 119 GraphicsDevice.Clear(Color.White);
63a61ee2
BB
120
121 spriteBatch.Begin();
122
74c15570
BB
123 ScreenManager.Draw(spriteBatch);
124
125 spriteBatch.DrawString(DebugFont, "Score: " + Player.Score.ToString(), new Vector2(10, 10), Color.LightGray);
126 spriteBatch.DrawString(DebugFont, "Multiplier: " + Player.Multiplier.ToString(), new Vector2(10, 30), Color.LightGray);
127 spriteBatch.DrawString(DebugFont, "Lives: " + Player.Lives.ToString(), new Vector2(10, 50), Color.LightGray);
63a61ee2
BB
128
129 spriteBatch.End();
130
131 base.Draw(gameTime);
132 }
133 }
134}